package com.zixun.activity;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.zixun.Models.Message;
import com.zixun.R;
import com.zixun.db.DatabaseUtil;

import java.util.List;


/**
 *   郭郭
 */
public class HomeDetailActivity extends Activity {

    private TextView center_text;
    private ImageView detail_img;
    private TextView detail_text;
    private String tag;
    private DatabaseUtil mUtil;
    private List<Message> list = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.home_detail_layout);

        initView();
        initData();
    }

    private void initView() {
        center_text = (TextView) findViewById(R.id.center_text);
        detail_img = (ImageView) findViewById(R.id.detail_img);
        detail_text = (TextView) findViewById(R.id.detail_text);
    }

    private void initData() {
        center_text.setText("详细信息");
        tag = getIntent().getStringExtra("tag");
        //获取数据库
        mUtil = new DatabaseUtil(HomeDetailActivity.this);
        list = mUtil.queryAll();

        switch (tag){
            case "0":
                detail_img.setBackgroundResource(R.mipmap.detail_1);
                detail_text.setText(list.get(0).getDescription());
                break;
            case "1":
                detail_img.setBackgroundResource(R.mipmap.detail_2);
                detail_text.setText(list.get(1).getDescription());
                break;
            case "2":
                detail_img.setBackgroundResource(R.mipmap.detail_3);
                detail_text.setText(list.get(2).getDescription());
                break;
            case "3":
                detail_img.setBackgroundResource(R.mipmap.detail_4);
                detail_text.setText(list.get(3).getDescription());
                break;
            case "4":
                detail_img.setBackgroundResource(R.mipmap.detail_5);
                detail_text.setText(list.get(4).getDescription());
                break;
        }

    }

}
